import { type EventChannel, getCurrentInstance } from "@tarojs/taro"

export function useNavigateEventChannel() {
  const page = getCurrentInstance().page!
  const eventChannel = page.getOpenerEventChannel!() as EventChannel
  return {
    eventChannel: eventChannel && typeof eventChannel.on === "function" ? eventChannel : null
  }
}
